<docs>
  ##
</docs>
<template>
  <div>
    <div class="content">
    <div class="header">
      <span class="arrow" @click="back_btn"></span>
      <h3 class="title">职位详情</h3>
    </div>
      <div class="position margin clearfix">
        <div class="left">
          <p class="title clearfix">
            <span class="item_left">{{gwxx.gwmc}}</span>
            <span class="sc"
            v-if="errorFlag"
            :class="[gwxx.sfdl=='0' ? 'not_allowed':'']"
            @click="sc(gwxx.sfdl)">
              {{collect}}
              <img src="~common/images/collect.png" alt="">
            </span>
          </p>
          <p class="money clearfix">
            <!-- <span class="item_left"><span class="num">{{gwxx.xcfw}}</span>/月</span> -->
            <span class="item_left"><span class="num">{{gwxx.xcfw}}</span></span>
            <span class="gw"
              v-if="errorFlag"
              @click="back_Seach">
            相似岗位<img src="~common/images/xsgw.png" alt=""></span>
          </p>
          <p class="clearfix">
            <span class="item_left">{{gwxx.nlfw}}/{{gwxx.whcd_xs}}/{{gwxx.ygxs_xs}}</span>
            <span
            v-if="errorFlag"
            :class="[ flag === '1' || gwxx.sfyjycsqy == '0'? 'not_allowed resume' : 'resume']"
             @click="tdjlHandle(gwxx.sfyjycsqy)">投递简历
              <img src="~common/images/deliver.png" alt="">
            </span>
          </p>
        </div>
      </div>
      <div class="common margin">
        <div class="title tem_comm">
          <p><span></span>工作地区</p>
        </div>
        <div class="edu_list tem_comm">
          <p>{{gwxx.gzdq_xs}}</p>
        </div>
      </div>
      <div class="common margin">
        <div class="title tem_comm">
          <p><span></span>职位描述</p>
        </div>
        <div class="pos_com tem_comm">
          <p><span>岗位要求：</span><span class="span_" v-html="gwxx.gwyq"></span></p>
          <p><span>岗位职责：</span><span class="span_" v-html="gwxx.gzzz"></span></p>
        </div>
      </div>
      <div class="common margin message">
        <div class="title tem_comm">
          <p><span></span>公司信息</p>
        </div>
        <div class="pos_com tem_comm" >
          <router-link v-if="errorFlag"
          :to="{ name: 'newcompanyDetail', query: {id: gwxx.dwdjid}}"
           class="link_img"><span>单位名称：</span>{{gwxx.dwmc}}<img src="~common/images/lianjie.png" alt=""></router-link>
          <p><span>单位性质：</span>{{gwxx.dwxz_xs}}</p>
          <!-- <p><span>公司规模：</span>{{gwxx.qygm_xs}}</p> -->
        </div>
      </div>
    </div>
    <!-- 投递简历弹框 -->
    <sub-confirm :visible.sync="visibleResume" :jlxx="jlxx" @qrtd="toudi"></sub-confirm>
  </div>
</template>
<script>
import Tankuang from 'base/jltd/jltd';
import store from '@/store/index';
import $ from '@/common/js/axios';

export default {
  name: 'newjobDetail',
  components: { Tankuang },
  data() {
    return {
      errorFlag: true,
      flag:"",
      sight:"",
      visibleResume: false,
      collect:"收藏",
      gwxx: {
        zpgwid: '',
        dwmc: '',
        dwxz: '',
        qygm: '',
        dwdjid: '',
        gwmc: '',
        gzdq: '',
        gzdq_xs: '',
        gzdd: '',
        ygxs_xs: '',
        xcfw: '',
        gznrms: '',
        whcd_xs: '',
        fldy:""
      },
      jlxx: {},
      qwss: '',
      formDate:{
        jlid: "",
        zpgwid: "",
        sftxtdjl: ""
      },
      tdxx:{
        sftxtdjl:""
      }
    };
  },
  methods: {
    // 收藏
    sc(n){
      if (n == '0') return;
      var form = {
        grqzid: this.jlxx.grqzid,
        zpgwid: this.qwss,
        sfsc: this.sight= this.sight=='1'?'0':'1'
      }
      $.post('/grgl/zpgwscBc',form).then(res => {
        const data = res.returnData;
        if (+data.executeResult === 1) {
          if (this.sight == '0') {
            this.sight == '1';
            this.collect ='收藏';
          }else{
            this.sight == '0';
            this.collect ='已收藏';
          }
            this.$toast(data.message);
          }else{
            this.$toast(data.message)
          }
      });
    },
    // 点击投递简历 判断
    tdjlHandle(n) {
      // this.GET_personInfo().then(res=>{
      //   if(res.returnData.sfdl == '1'){
      if (this.gwxx.sfdl == '0') {
        window.location.href = './public3.html';
        return
      }
      // 已投递判断
      if (this.flag == '1' || n == '0') return;
      if (!this.jlxx.jlid){
        this.$alert("请维护简历信息后投递！");
        return ;
      }
      //判断显示投递简历弹框
      if(this.gwxx.sftxtdjl != 1){
        this.visibleResume = true;
      }else{
        this.toudi('flag');
      }
      //   }
      // });
    },
    // 投递简历
    toudi(data) {
      this.formDate.jlid = this.jlxx.jlid;
      this.formDate.zpgwid = this.qwss;
      this.$loading = true;
      if(data === 'flag' || data){
        this.formDate.sftxtdjl = '1'
      }else{
        this.formDate.sftxtdjl = '0'
      }
      $.post('/grgl/jltdxxBc', this.formDate)
        .then(res => {
          if (+res.returnCode === 1) {
            this.visibleResume = false;
            this.$alert(res.returnData.message,()=>{
              this.flag = '1';
            });
          }
        })
        .finally(() => {
          this.$loading = false;
        });
    },
    GET_personInfo() {
      return this.$http.get("/grgl/sfyqzdj");
    },
    // 获取招聘信息
    Search() {
      this.qwss = this.$route.query.dm;
      $.get('/grcptj/zpxqCx', {
        params: {
          zpgwid: this.qwss
        }
      }).then(res => {
        const data = res.returnData;
        if (data.executeResult == 1) {
          this.gwxx = data.gwxx;
          if (data.gwxx.gwyq) {
            this.gwxx.gwyq = this.gwxx.gwyq.replace(/\|BKSX\|/g,"<br>");
          }
          if(this.gwxx.gzzz){
            this.gwxx.gzzz = this.gwxx.gzzz.replace(/\|BKSX\|/g,"<br>");
          }
          //是否收藏简历 标识 1收藏； 0未收藏
          this.sight = this.gwxx.sfysc;
          this.collect = this.sight == '1'?'已收藏':'收藏';
          //是否投递简历 标识 1投递； 0未投
          this.flag = this.gwxx.sfytdjl;
        }else{
          this.errorFlag = false;
          this.$alert(res.returnData.message,()=>{
            this.$router.go(-1);
          });
        }
      });
    },
    // 相似岗位
    back_Seach(){
      const mtachJob = {
        // whcd: this.gwxx.whcd,
        qwgjz:this.gwxx.gwmc,
        zdyx:this.gwxx.zdyx,
        zgyx:this.gwxx.zgyx,
        dwhy: [],
        dwzy: [],
        gzdd: [],
        xscxwhcd: this.gwxx.whcd,
        pageSize: "10"
      };
      sessionStorage.setItem("entity", JSON.stringify(mtachJob));
      // if (this.$store.state.likeJobName) {
      //   // sessionStorage.setItem("qwgjz", this.gwxx.gwmc);
      //   sessionStorage.setItem("entity", mtachJob);
      // }
      this.$router.push({name:"newSearch",query:{obj:'1'}})
    },
    // 获取简历列表
    Resume_list() {
      $.get('/grgl/jlxxCx').then(res => {
        const data = res.returnData;
        this.jlxx = data.jlxx;
      });
    },
    back_btn(){
      if(this.$route.query.look == 1){
        this.$router.push({path:'/user/tdList'});
      }else {
        this.$router.go(-1);
      }
    }
  },
  /* eslint-disable consistent-return */
  beforeRouteLeave(to, from, next) {
    if (to.name == 'newSearch') {
      to.query.obj='1';
    }
    next();
  },
  // 我的集合下，页面进入
  // beforeRouteEnter (to, from, next) {
  //   if (from.name == 'newSearch' || from.name == 'home') {
  //     store.commit('SET_LIKEJOBNAME_GO', false);
  //   } else {
  //     store.commit('SET_LIKEJOBNAME_GO', true);
  //   }
  //   next();
  // },
  created() {
    this.Search();
    this.Resume_list();
  }
};
</script>
<style scoped lang="scss">
@import '~common/scss/var.scss';
._detail{
  background: linear-gradient(90deg, #1d66d4, #00baff);
}

.left {
  padding: 30px;
  overflow: hidden;
  img {
    width: 118px;
    height: 118px;
    vertical-align: middle;
    margin: 30px 20px 0 30px;
  }
  p {
    color: $color-text-primary;
    padding-bottom: 30px;
    height: $font-size-ultra;
    line-height: $font-size-ultra;
    .num{
      color: #fb4d64;
      font-size: $font-size-base;
    }
    .item_left{
      float: left;
    }
  }
  p:last-child{
    padding-bottom: 0;
  }
  .title {
    color: #0096FF;
    // margin: $radius-base3*2 0;
  }
  .sc, .gw, .resume {
    float: right;
    background-color: #ff9900;
    padding: 0 $radius-base;
    box-sizing: border-box;
    color: #fff;
    font-size: $padding-base-half * 3;
    border-radius: $padding-base-half;
    img{
      height: $padding-base * 2;
      width: $padding-base * 2;
      vertical-align: sub;
      margin: 0;
    }
  }
  .not_allowed{
    background-color: #ccc;
  }
  .gw img,.resume img, .sc img {
    margin-left: $padding-base/2;
  }
}
.margin {
  margin-bottom: 20px;
}
.content{
  background-color: #F1F1F1;
  // padding: $padding-base;
.position {
  // height: 180px;
  background-color: #fff;
}
.common {
  // min-height: 175px;
  background-color: #fff;
  .tem_comm {
    width: 90%;
    margin: 0 auto;
    p {
      font-size: $font-size-base;
    }
  }
  .title {
    height: 90px;
    line-height: 90px;
    border-bottom: 1px solid #dbdbdb;
    color: $color-text-title;
    font-weight: bold;
    span {
      width: 10px;
      height: 30px;
      border-radius: 10px;
      background-color: $color-base;
      margin-right: 10px;
      display: inline-block;
    }
  }
  .edu_list {
    line-height: 84px;
    border-left: none;
    p {
      color: $color-text-primary;
    }
  }
  .pos_com {
    line-height: 60px;
    margin: 20px auto 0;
    padding-bottom: 20px;
    // color: #999;
    span {
      font-weight: bold;
      color: #666;
    }
    .span_spac {
      font-weight: normal;
    }
    .span_{
      color: #999;
      font-weight: 400;
    }
  }
}

}
.message {
  margin-bottom: 20px;
}
.link_img img{
  height: $font-size-mini;
  margin-left: 5px;
}
</style>
